package com.ymatou.apigateway.service;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class SqFullRefundCall extends YmatouBaseCall {
	
	private static String opurl = "api/v1?method=sq.order.fullrefund";

	public SqFullRefundCall() {
		super(EnvSetup.getSystemUrl("apigateway"), opurl, "POST", "JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).optString("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).optString("message");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取content
	 * 
	 * @return
	 */
	public JSONObject getContent() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("content");
		} catch (Exception e) {
			//e.printStackTrace();
			return null;
		}
		return Data;
	}

	/**
	 * 获取results
	 * 
	 * @return
	 */
	public JSONArray getResults() {
		JSONObject Data = getContent();
		try {

			return Data.getJSONArray("results");

		} catch (Exception e) {
			//e.printStackTrace();
			return null;
		}
	}
}
